import { request } from '@/http';

export function getUserInfo() {
  return request.post('/api/member/info');
}

type SetUserInfoPayload = {
  sex: number;
  avatar: string;
  first_name: string;
  last_name: string;
  nationality: string;
  birthday: string;
};

export function setUserInfo(payload: Partial<SetUserInfoPayload>) {
  return request.post('/api/member/add_user_information', payload);
}

export function sendEmailCode(email: string) {
  return request.post('/api/member/SendEmailCode', { email });
}

type SetEmailPayload = {
  email: string;
  code: string;
};

export function bindEmail(payload: Partial<SetEmailPayload>) {
  return request.post('/api/member/bindEmail', payload);
}

export function sendPhoneCode(area_no: string, phone: string) {
  return request.post('/api/member/SendPhoneCode', { area_no: area_no, phone: phone });
}

type SetPhonePayload = {
  AreaNo: string;
  Phone: string;
  Code: string;
};

export function bindPhone(payload: Partial<SetPhonePayload>) {
  return request.post('/api/member/bindPhone', payload);
}

type PointsListPayload = {
  pageNum: number;
  pageSize: number;
  changeMode: string;
};

export function getPointsList(payload: PointsListPayload) {
  return request.post('/api/balanceChange/list', payload);
}

export function getLevelRule() {
  return request.post('/api/member/levelRule');
}

export function userCancel(cancelReason: string) {
  return request.post('/api/member/cancel', { cancelReason });
}

type MessageListPayload = {
  pageNum: number;
  pageSize: number;
};

export function getMessageList(payload: MessageListPayload) {
  return request.post('/api/pmsNotify/list', payload);
}

type CouponListPayload = {
  page: number;
  pageSize: number;
  state: number;
};

export function getCouponList(payload: CouponListPayload) {
  return request.post('/api/couponList', payload);
}

export function getCouponDetailsById(id: string) {
  return request.post('/api/couponDetail', { id });
}

export function getHelpCategory() {
  return request.post('/api/pmsHelpcenterCategory/list');
}

type HelpListPayload = {
  categoryId: number;
  title: string;
};

export function getHelpList(payload: HelpListPayload) {
  return request.post('/api/pmsHelpcenter/list', payload);
}

export function getHelpDetail(id: number) {
  return request.post('/api/pmsHelpcenter/view', { id });
}

type CollectListPayload = {
  page: number;
  pageSize: number;
  collectType: string;
};

export function getCollectList(payload: CollectListPayload) {
  return request.post('/api/pmsCollect/list', payload);
}

export function delCollect(id: number) {
  return request.post('/api/pmsCollect/delete', { id });
}

type AddCollectListPayload = {
  collectId: number;
  collectType: string;
};

export function addCollect(payload: AddCollectListPayload) {
  return request.post('/api/pmsCollect/add', payload);
}

export function staffInfo(StaffId: number) {
  return request.post('/api/member/staffInfo', { StaffId });
}

export function channelInfo(ChannelId: number) {
  return request.post('/api/member/channelInfo', { ChannelId });
}

export function staffFxInfo(StaffId: number) {
  return request.post('/api/staff/fxCenter', { StaffId });
}

export function channelFxInfo(ChannelId: number) {
  return request.post('/api/channel/fxCenter', { ChannelId });
}

type CommissionListPayload = {
  PageNum: number;
  PageSize: number;
  ChannelId: number;
  StaffId: number;
  rebateStatus: string;
};

export function getCommissionList(payload: CommissionListPayload) {
  return request.post('/api/brokerage/list', payload);
}

export function getCommissionDetail(id: number) {
  return request.post('/api/brokerage/detail', { id });
}

type ReferrerPayload = {
  pageNum: number;
  pageSize: number;
};

export function getReferrerInfo(payload: ReferrerPayload) {
  return request.post('/api/referrer/info', payload);
}

type WithdrawInfoPayload = {
  ChannelId: number;
  StaffId: number;
};

export function withdrawInfo(payload: WithdrawInfoPayload) {
  return request.post('/api/brokerage/withdraw', payload);
}

type WithdrawApplyPayload = {
  ChannelId: number;
  StaffId: number;
  amount: number;
};

export function withdrawApply(payload: WithdrawApplyPayload) {
  return request.post('/api/brokerage/withdrawApply', payload);
}

type WithdrawnListPayload = {
  PageNum: number;
  PageSize: number;
  ChannelId: number;
  StaffId: number;
  withdrawStatus: string;
};

export function getWithdrawList(payload: WithdrawnListPayload) {
  return request.post('/api/brokerage/withdrawList', payload);
}

export function getWithdrawDetail(id: number) {
  return request.post('/api/brokerage/withdrawDetail', { id });
}

export function getIntentionConfig() {
  return request.post('/api/member/intention_config');
}

type AddIntentionPayload = {
  country: string;
  phone: string;
  phoneArea: string;
  language: string;
  mail: string;
  remark: string;
  wechatNo: string;
  lineId: string;
};

export function addIntention(payload: AddIntentionPayload) {
  return request.post('/api/member/add_intention', payload);
}
